<?php 


CREATE TABLE user (
  id int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主建',
  email varchar(50) NOT NULL COMMENT '邮箱' ,
  password varchar(32) NOT NULL COMMENT '密码' ,
  username varchar(50) NOT NULL DEFAULT '' COMMENT '用户名' ,
  status int(1) DEFAULT 0 COMMENT '状态（0正常，1禁止）' ,
  sex enum('保密','女','男') NOT NULL DEFAULT '保密' COMMENT '性别',
  face varchar(100)  COMMENT '头像' ,
  site varchar(50)  COMMENT '个性网址' ,
  birthday date DEFAULT '1990-01-04' COMMENT '性别',
  city varchar(20)  COMMENT '城市' ,
  addr varchar(50)  COMMENT '通信地址' ,
  psite int(10) unsigned DEFAULT NULL COMMENT '个人网址',
  introduce varchar(300)  COMMENT '自我介绍 ',
  rank int() COMMENT '声望' ,
  reg_time int(10) COMMENT '注册时间',
  reg_ip varchar(15) COMMENT '注册IP',
  login_time int(10) COMMENT '最后登录时间',
  ligin_ip varchar(15) COMMENT '最后登录IP',
  PRIMARY KEY (id),
  UNIQUE email (email)
) ENGINE=Myisam AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT '用户表';



CREATE TABLE category (
  id int(2) unsigned NOT NULL AUTO_INCREMENT COMMENT '主建',
  fid int(2) NOT NULL DEFAULT 0 COMMENT '父类ID' ,
  cname varchar(50) NOT NULL COMMENT '分类名称' ,
  cintroduce varchar(50) NOT NULL COMMENT '分类介绍' ,
  PRIMARY KEY (id)
) ENGINE=Myisam AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT '分类表';



CREATE TABLE question (
  id int(2) unsigned NOT NULL AUTO_INCREMENT COMMENT '主建',
  status int(1) not null default 0 COMMENT '状态（0未被回复，1正常，2冻结，3删除）' ,
  title varchar(50) NOT NULL COMMENT '问题标题' ,
  content text NOT NULL COMMENT '问题内容' ,
  create_time int(10)  COMMENT '创建时间' ,
  uid int(10)  COMMENT '提问者' ,
  view int(6)  COMMENT '浏览次数' ,
  answer_num int(6)  COMMENT '回答次数' ,
  vote_num int(6)  COMMENT '投票' ,
  focus_num int(6)  COMMENT '关注次数' ,
  fav_num int(6)  COMMENT '收藏次数' ,
  PRIMARY KEY (id)
) ENGINE=Myisam AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT '问题表';




CREATE TABLE category_question (
  id int(2) unsigned NOT NULL AUTO_INCREMENT COMMENT '主建',
  cid int(2) COMMENT '分类id',
  qid int(6) COMMENT '问题id',
  PRIMARY KEY (id)
) ENGINE=Myisam AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT '分类与问题中间表';


CREATE TABLE  answer (
  id int(2) unsigned NOT NULL AUTO_INCREMENT COMMENT '主建',
  fid int(2) NOT NULL DEFAULT 0 COMMENT '父类ID' ,
  qid int(2) NOT NULL DEFAULT 0 COMMENT '问题ID' ,
  uid int(10)  COMMENT '回答者' ,
  vote_num int(6)  COMMENT '投票次数' ,
  content text NOT NULL COMMENT '回答内容' ,
  create_time int(10)  COMMENT '创建时间' ,
  PRIMARY KEY (id)
) ENGINE=Myisam AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT '回答表';



CREATE TABLE  qestion_vote (
  id int(2) unsigned NOT NULL AUTO_INCREMENT COMMENT '主建',
  qid int(2) NOT NULL DEFAULT 0 COMMENT '问题ID' ,
  uid int(10)  COMMENT '投票者' ,
  create_time int(10)  COMMENT '创建时间' ,
  PRIMARY KEY (id)
) ENGINE=Myisam AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT '问题投票'; 


CREATE TABLE  answer_vote (
  id int(2) unsigned NOT NULL AUTO_INCREMENT COMMENT '主建',
  qid int(2) NOT NULL DEFAULT 0 COMMENT '问题ID' ,
  uid int(10)  COMMENT '投票者' ,
  create_time int(10)  COMMENT '创建时间' ,
  PRIMARY KEY (id)
) ENGINE=Myisam AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT '回答投票'; 

 

CREATE TABLE  focus (
  id int(2) unsigned NOT NULL AUTO_INCREMENT COMMENT '主建',
  qid int(2) NOT NULL DEFAULT 0 COMMENT '问题ID' ,
  uid int(10)  COMMENT '关注者' ,
  create_time int(10)  COMMENT '创建时间' ,
  PRIMARY KEY (id)
) ENGINE=Myisam AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT '关注'; 



CREATE TABLE  favorite (
  id int(2) unsigned NOT NULL AUTO_INCREMENT COMMENT '主建',
  qid int(2) NOT NULL DEFAULT 0 COMMENT '问题ID' ,
  uid int(10)  COMMENT '收藏者' ,
  create_time int(10)  COMMENT '创建时间' ,
  PRIMARY KEY (id)
) ENGINE=Myisam AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT '收藏'; 


CREATE TABLE report (
  id int(2) unsigned NOT NULL AUTO_INCREMENT COMMENT '主建',
  qid int(2) NOT NULL DEFAULT 0 COMMENT '问题ID' ,
  uid int(10)  COMMENT '举报' ,
  content varchar(50) not NULL COMMENT '举报问题' ,
  create_time int(10)  COMMENT '创建时间' ,
  PRIMARY KEY (id)
) ENGINE=Myisam AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT '举报'; 



CREATE TABLE  rank (
  id int(2) unsigned NOT NULL AUTO_INCREMENT COMMENT '主建',
  rank int(3) COMMENT '声望值' ,
  uid int(10)  COMMENT '用户' ,
  event varchar(50) not NULL COMMENT '事件' ,
  event_id int(6) not NULL COMMENT '事件ID' ,
  create_time int(10)  COMMENT '创建时间' ,
  PRIMARY KEY (id)
) ENGINE=Myisam AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT '声望';



















 ?>